/**
 *发布
 */
var mongoose  = require('mongoose');
var BaseModel = require("./base_model");
var Schema    = mongoose.Schema;

var PublishSchema = new Schema({
    name:{             //商品名，从PublishConfig中获得
        type:String,
        require: true
    },
    version:{           //商品版本，对某个商品唯一
        type: String,
        required: true
    },
    publish_config:{
        type:Schema.Types.ObjectId,
        ref:'PublishConfig',
        required:true
    },
    product_info:[{       //根据publish_config获得product_configs，在product中获得产品信息
        fileName:String,  //包含后缀的产品文件名
        type:{
            type: String
        },      //mk_back|mk_front|app_android|app_ios 与product_cfg中一致
        version:String,   //与product_cfg中一致
        name:String       //产品名
    }],
    description:String,   //描述，主要用于更新时说明
    create_at: {
        type: Date, default: Date.now
    },
    update_at: {
        type: Date, default: Date.now
    },
    state:{
        type:String,
        default: "create" // ready | uploading | upload_failed | uploaded | published
    }
});

PublishSchema.plugin(BaseModel);
mongoose.model('Publish', PublishSchema);